package al.jdbc.dpbridge;

import java.sql.Connection;
import java.sql.DriverManager;

public class DataSource {
	private String driver;
	private String url;
	private String user;
	private String password;
	
	public DataSource() {
	}

	public DataSource(String driver, String url, String user, String password) {
		super();
		this.driver = driver;
		this.url = url;
		this.user = user;
		this.password = password;
	}
	
	public Connection getConnection() {
		try {
			// 1. Charger le Driver
			Class.forName(driver);
			
			// 2. Ouverture de la connexion :
			Connection db = DriverManager.getConnection(url, user, password);
			return db;
		}
		catch (Exception e) {
			System.out.println("Erreur : " + e.getMessage());
			return null;
		}
	}
}
